<?php
// $Id: photos.page.inc,v 1.0 2008/7/23 12:50 east Exp $
function photos_quote() {
	global $user;
	$content = '<div id="TB_title"><div id="TB_ajaxWindowTitle">从我的图片库中选取图片</div><div id="TB_closeAjaxWindow"><a onclick="self.parent.tb_remove();" href="#">点此关闭</a></div></div>';
	$content .= _photos_teee($user->uid);
	echo theme('photos_quote_page', $content);
	exit();
}
function _photos_teee($uid) {
	$x = drupal_get_form('_photos_opalbum_form',$uid).'<div class="photo-msg"></div>';
	if(is_numeric($_GET['type'])){
		$pid = $_GET['type'];
	}
	if(!$pid){
		$p = _photos_sql('allimage','WHERE uid = '.$uid,20);
	}else{
		$p = _photos_sql('allimage','WHERE uid = '.$uid.' AND pid = '.$pid,20);
	}
	if($p){
		foreach ($p as $b) {
			$t = _photos_get_path($b->fid);
			$title = !empty($t['title']) ? $t['title']:$t['ptitle'];
			$x .= '<div class="photos-quote"><img src="/'.$t['p1'].'"><div class="photo-input"><div><input class="photos-p" type="checkbox" value="'.$t['p1'].'&&&'.$title.'&&&'.$b->fid.'" name="photos-p[]"/>插入缩略图</div><input class="photos-p" type="checkbox" value="'.$t['p2'].'&&&'.$title.'&&&'.$b->fid.'" name="photos-pp[]"/>插入适中尺寸</div></div>';
	   };
		$x .= theme('pager', NULL, 20);
	}
	return $x;
}
function _photos_opalbum_form(&$form_state,$uid) {
	$form['albumsubmit'] = array(
		'#type' => 'submit',
		'#value' => '选择相册',
		'#submit' => array('_photos_opalbum_form_submit'),
		'#prefix' => '<div class="albumselect">',
  		'#suffix' => '</div>',
	);
	$form['albumselect'] = array(
		'#type' => 'select',
		'#options' => _photos_useralbum($uid),
		'#default_value' => $_GET['type'],
		'#prefix' => '<div class="albumselect">',
  		'#suffix' => '</div>',
	);
	$form['albumvalue'] = array(
		'#value'=>'<a class="clickimage" href="#">插入选中图片</a>'.l('上传新图片','photos/upload',array('query'=>drupal_get_destination())),
		'#prefix' => '<div class="albumselect">',
		'#suffix' => '</div><div style="clear:both"></div>',
  	);

	return $form;
}
function _photos_opalbum_form_submit($form, &$form_state,$uid) {
	$u = $form_state['values']['albumselect'];
	drupal_goto('photos/quote',array('type' => $u));
}
function photos_test_page() {
	drupal_goto('photos/image');
}
function _photos_image_pager($fid,$view,$sql) {

	$set = 'SELECT fid FROM {x_image} WHERE '.$sql.' fid < '.$fid.' ORDER BY fid DESC';
	$skt = 'SELECT fid FROM {x_image} WHERE '.$sql.' fid > '.$fid.' ORDER BY fid ASC';
	$prev = db_result(db_query('SELECT count(fid) FROM {x_image} WHERE '.$sql.' fid < '.$fid));
	$next = db_result(db_query('SELECT count(fid) FROM {x_image} WHERE '.$sql.' fid > '.$fid));
	$a = db_query_range($set,1);
	$au = db_result(db_query($skt));
	$b = db_query_range($skt,1);
	if($view) {$arg = '/'.$view;}
	$true = false;
	while ($c = db_fetch_object($a)){
		$mx .= photos_view_image($c->fid,'all',$view);
		$mv .= l('上一张','photos/image/'.$c->fid.$arg,array('attributes'=>array('title'=>'还有 '.$prev.' 张图片')));
		$true = true;
	}
	if(!$true){
		$mx .= '<img src="/'.drupal_get_path(module,photos).'/img/d.jpg">';
		$mv .= '<span class="a">没有了</span>';
	}
	$mv .= '<span class="a">▲</span>';
	$mx .= photos_view_image($fid,'all',$view);
	$true = false;
	while ($d = db_fetch_object($b)){
		$mx .= photos_view_image($d->fid,'all',$view);
		$mv .= l('下一张','photos/image/'.$d->fid.$arg,array('attributes'=>array('title'=>'还有 '.$next.' 张图片')));
		$true = true;
	}	
	if(!$true){
		$mx .= '<img src="/'.drupal_get_path(module,photos).'/img/d.jpg">';
		$mv .= '<span class="a">没有了</span>';
	}
	$output = '<div class="image-prev">'.$mx.'<div class="image-link">'.$mv.'</div></div>';
	return $output;
}

function photos_imagenode_page($node){
	$output = '<div class="album-a ">'.l('上传图片','node/'.$node->nid.'/photos') .l('新建相册','node/add/photos').'</div>';
	if($node->type == 'photos'){
		if($node->album['count']){ 
			$title = '相册下共有 '.$node->album['count'].' 张图片';
		}else{
			$title = '相册下还没有图片';
		}
		$output .= photos_allimage_page('WHERE pid = '.$node->nid,40,'album');
	}elseif(variable_get('photos_'.$node->type, 0)){
		if($node->photos['count']){ 
			$title = '文章下共有 '.$node->photos['count'].' 张图片';
		}else{
			$title = '文章下还没有图片';
		}
		$output .= photos_allimage_page('WHERE nid = '.$node->nid,40,'node');
	}else{
		drupal_not_found();
	}
	drupal_set_title('图片浏览: '.$node->title);
	drupal_set_breadcrumb(array(l(t('Home'),NULL),l($node->title,'node/'.$node->nid),$title));
    return $output;
}

//单张图片编辑表单
function photos_desedit(&$form_state,$edit){
	if(_photos_access('edit',$edit['uid'])){
	$form['des'] = array('#type' => 'textarea','#default_value' => '','#cols' => 40, '#rows' => 3);
	$form['uid'] = array('#type' => 'value','#value' => $edit['uid']);
	$form['del'] = array(
		'#title' => '删除',
		'#type' => 'checkbox',	
		'#prefix' => '<div style="float:left; margin:0 5px;">',
		'#suffix' => '</div>',
	);
	$form['wid'] = array(
		'#title' => '排序',
		'#type' => 'weight',
		'#default_value' => $edit['wid'],
		'#prefix' => '<div style="float:left; margin:0 10px;">',
		'#suffix' => '</div>',
	);
	$form['fid'] = array(
		'#type' => 'value',
		'#default_value' => $edit['fid'],
	);
	$form['submit'] = array(
		'#type' => 'submit',
		'#value' => '确认更改',
		'#submit' => array('photos_desedit_submit'),
		'#prefix' => '<div style="float:left; margin:0;">',
  		'#suffix' => '</div>',
	);
	}else{
		$form['errer'] = array('#value'=>'你没有登录或没有权限操作这张图片。');
	}
	$form['editnone'] = array(
		'#type' => 'button',
		'#value' => '取消操作',
		'#prefix' => '<div style="float:left; margin:0;">',
  		'#suffix' => '</div>',
	);
	return $form;
}

//单张图片编辑提交处理
function photos_desedit_submit($form, &$form_state) {
	global $user;
	if (!empty($form_state['values']['del'])) {
		_photos_file_del($$form_state['values']['fid']);
		$t = db_query('DELETE FROM {x_image} WHERE fid = %d',$form_state['values']['fid']);
		if($t){
			$a = '删除成功';
		}else{
			$a = '删除失败';
		}
		drupal_set_message($a);
		drupal_goto('photos/user/image/'.$form_state['values']['uid']);
	}else{
		$t = db_query("UPDATE {x_image} SET des = '%s', wid = %d WHERE fid = %d", $form_state['values']['des'], $form_state['values']['wid'], $form_state['values']['fid']);
		if($t){
			$a = '修改成功';
		}else{
			$a = '修改失败';
		}
		drupal_set_message($a);
	}
}

function photos_allimage_page($sql,$num,$view){
	$a = _photos_sql('allimage',$sql,$num);
	if($a){
		$output = '<div class="photos-a">';
		foreach ($a as $b) {
			$output .= photos_view_image($b->fid,'all',$view);
	   };
		$output .= '</div>'.theme('pager', NULL, $num);
	}else{
		$output .= '';
	}
    return $output;
}

function photos_image_pageone(){
	$m = '<div class="album-a">图片不存在。'.l('上传一个图片','photos/upload').l('新建一个相册','node/add/photos').'</div>';
	if(!is_numeric(arg(2))){
		return $m;
	}

	if(arg(1)=='image'){
		$output = photos_view_image(arg(2),'view',arg(3));
	}else{
		$p = _photos_get_path(arg(2));
		if($p){
			if($p['pid']) { $pid = l('返回相册','node/'.$p['pid'].'/photos/view');}
			if($p['nid']) { $pid .= l('返回文章','node/'.$p['nid'].'/photos/view');}
			$output = '<div class="photo-zoom">'.l('原始尺寸','photos/zoom/'.arg(2)).l('适中尺寸','photos/zoom/'.arg(2).'/2').l('缩略图','photos/zoom/'.arg(2).'/1').l('查看EXIF信息','photos/zoom/'.arg(2).'/exif').$pid.l('返回图片','photos/image/'.arg(2)).'</div>';
			if(arg(3) != 'exif'){
				$output .= '<div class="photo-zoom">图片引用链接：<input type="text" value="'.file_create_url($p['p'.arg(3)]).'" size="100" onmouseover="this.focus()" onfocus="this.select()"></div>';
			}
			switch (arg(3)) {
				case '':
					$output .= '<img src="/'.$p['p'].'">';
				break;
				case '1':
					$output .= '<img src="/'.$p['p1'].'">';
				break;
				case '2':
					$output .= '<img src="/'.$p['p2'].'">';
				break;
				case 'exif':
					$output .= _photos_getexif($p['p']);
					drupal_set_title('图片exif信息查看');
				break;
			}
		}else{
			$output = $m;
		}
	}
	return $output;
}

function photos_user_image_page(){
	$a =  _photos_num('image');
	if($a){
		$output =  '<div class="album-a">全站共有 '.$a.' 张图片。'._photos_num('album').' 个相册。'.l('查看全部相册','photos/album').l('新建相册','node/add/photos').l('上传图片','photos/upload').'</div>';
		$output .= photos_allimage_page('',50,'');
	}else{
		$output = '<div class="album-a">没有图片。'.l('新建一个相册','node/add/photos').l('上传一张图片','photos/upload').'</div>';
	}
    return $output;
}

function photos_user_album_page() {
	global $user;
	$tx = l('创建相册','node/add/photos').l('上传图片','photos/upload');
	if(arg(1)=='album'){
		$b = _photos_sql('album','',10);
		if($b){
			$output = '<div class="album-a">全站共有 '._photos_num('album').' 个相册， '._photos_num('image').' 张图片。'.l('查看全部图片','photos/image').$tx.'</div>';
			foreach ($b as $c){
			    $output .= photos_album_view($c->pid,'album');
		    };
		    $output .= theme('pager', NULL, 10);
	    }else{
			$output = '<div class="album-a">没有相册。'.l('新建一个相册','node/add/photos').l('上传一张图片','photos/upload').'</div>';
		}
	}elseif(is_numeric(arg(3))){
		$a = user_load(arg(3));
		if($a){
			$output = '';
			switch (arg(2)) {
				case 'image':
					$bread = l('图片','photos/image');
					if($user->uid == arg(3)){
						$title = '我的图片';
					}else{
						$title = $a->name.' 的图片';
					}
					$x = photos_allimage_page('WHERE uid = '.$a->uid,50,'user');
					$output = '<div class="album-a">';
					if($x){
						$output .= '<div class="album-a">共有 '.$a->photos['image'].' 张图片，'.$a->photos['album'].' 个相册。 '.l('查看相册','photos/user/album/'.$a->uid).$tx;
					}else{
						$output .= '没有图片。'.l('新建一个相册','node/add/photos').l('上传一张图片','photos/upload');
					}
					$output .= '</div>'.$x;
				break;
				case 'album':
					$bread = l('相册','photos/album');
					if($user->uid == arg(3)){
						$title = '我的相册';
					}else{
						$title = $a->name.' 的相册';
					}
					$b = _photos_sql('album','WHERE uid = '.$a->uid,10);
					if($b){
						$output = '<div class="album-a">共有 '.$a->photos['album'].' 个相册， '.$a->photos['image'].' 张图片。'.l('查看图片','photos/user/image/'.$a->uid).$tx.'</div>';
						foreach ($b as $c){
						    $output .= photos_album_view($c->pid,'album');
					    };
					    $output .= theme('pager', NULL, 10);
				    }else{
				    	$output = '<div class="album-a">没有相册。'.l('新建一个相册','node/add/photos').l('上传一张图片','photos/upload').'</div>';
				    }

				break;
			}
				drupal_set_title($title);
				drupal_set_breadcrumb(array(l('主页',NULL),$bread,drupal_get_title()));
		}
	}else{
		drupal_not_found();
	}

	return $output;
}

function photos_album_upload() {
	global $user;
	$u = user_load($user->uid);
	if(!$u->photos['album']){
		return '<h2>'.l('请先新建一个相册','node/add/photos',array('query'=>drupal_get_destination())).'</h2>';
	}
	$t .= drupal_get_form('photos_upload_form');
	return $t;
}
function photos_album_view($pid) {
	global $user;
    $node = node_load($pid);
    if($node){
	    $url = !empty($node->album['url']) ? $node->album['url']:drupal_get_path(module,photos).'/img/d.jpg';
	    $t .= '<div class="photos-album"><div class="album-left">'.l('<img src="/'.$url.'">','node/'.$node->nid.'/photos/view',array('html'=>true)).'</div><div class="album-right"><h2>'.l(check_plain($node->title),'node/'.$node->nid).'</h2><div>'.theme('username', $node).' 创建于 '.format_date($node->created, 'custom', "Y-m-j-H:s:i ").'<span class="photos-imgnum">共有 '.$node->album['count'].' 张图片</span></div>'.check_plain($node->teaser).'</div>';
	    if(_photos_access('edit',$node->uid)){
	    	$t .= '<div class="photos-editmenu">'.l('图片管理','node/'.$node->nid.'/photos').l('编辑相册','node/'.$node->nid.'/edit',array('query'=>drupal_get_destination())).'</div>';
	    }
	    $t .= '</div>';
	}

    return $t;
}

//图片管理
function photos_node_edit($node){
	if (variable_get('photos_'.$node->type, false)){
		$output = '你正在管理文章 '.l($node->title,'node/'.$node->nid).' 中的图片。共有 '.$node->photos['count'].' 张图片。';
		$title = '文章图片管理';
	}elseif($node->type == 'photos'){
		$output = '你正在管理相册 '.l($node->title,'node/'.$node->nid).' 中的图片。共有 '.$node->album['count'].' 张图片。';
		$title = '相册图片管理';
	}else{
		drupal_not_found();
		return;
	}
	drupal_set_title($title);
	drupal_set_breadcrumb(array(l('主页', NULL),l($node->title,'node/'.$node->nid),drupal_get_title()));
	$output .= drupal_get_form('photos_upload_form',$node);
	$output .= drupal_get_form('photos_editlist');
	return $output;

}
//站点图片管理
function photos_admin_edit(){
	$output = '';
	$output .= drupal_get_form('photos_editlist');
	return $output;
}

function photos_editlist() {
	$form['photos']['#theme'] = 'photos_editlist_x';
	$form['photos']['#tree'] = true;
	if(arg(1)=='admin'){
		$a = _photos_sql('node','f.status = 1',10);
	}else{
		$node = node_load(arg(1));
		if($node->type == 'photos'){
			$a = _photos_sql('node','i.pid = '.$node->nid,10);
		}else{
			$a = _photos_sql('node','i.nid = '.$node->nid,10);
		}
	}
	if($a){
		foreach ($a as $img) {
			$fid = $img->fid;
			if($node->type == 'photos'){
				if($img->nid){
					$tn = node_load($img->nid);
					$title = '上传在文章 '.l($tn->title,'node/'.$tn->nid). ' 中。';
				}
				$url = '/album';
			}elseif($img->pid){
				$tn = node_load($img->pid);
				$title = '分类在相册 '.l($tn->title,'node/'.$tn->nid). ' 中。';
				$url = '/node';
			}
			$p = _photos_get_path($fid);	
			$form['photos'][$fid]['del'] = array('#type' => 'checkbox');
			$form['photos'][$fid]['path'] = array('#value' => l('<img src="/'.$p['p1'].'">','photos/image/'.$fid.$url,array('html'=>true)));
			$form['photos'][$fid]['des'] = array('#type' => 'textarea','#default_value' => $img->des,'#cols' => 40, '#rows' => 4);
			$form['photos'][$fid]['time'] = array('#value' => '本张图片上传于 '.format_date($img->timestamp, 'custom', "Y-m-j H:s:i ").'。'.$title);
			$form['photos'][$fid]['wid'] = array('#type' => 'weight','#default_value' => $img->wid,);
		$form['photos'][$fid]['pid'] = array(
			'#type' => 'select',
			'#options' => _photos_useralbum($img->uid),
			'#default_value' => $img->pid,
			'#required' => TRUE,
		  );
			$form['photos'][$fid]['uid'] = array('#type' => 'hidden','#default_value' => $img->uid,);
		};
	}
	$form['allck'] = array('#value' =>'<a class="allck" href="javascript:void(0)">全选</a> | <a class="allnone" href="javascript:void(0)">取消选择</a>');
	$form['submit'] = array(
		'#type' => 'submit',
		'#value' => '确认更改',
		'#submit' => array('photos_editlist_submit'),
	);
	return $form;
}

function photos_editlist_submit($form, &$form_state) {
	global $user;
	foreach($form_state['values']['photos'] as $fid => $key) {
		if (!empty($key['del'])) {
			_photos_file_del($fid);
			db_query('DELETE FROM {x_image} WHERE fid = %d',$fid);
		}else{
			db_query("UPDATE {x_image} SET pid = %d, des = '%s', wid = %d WHERE fid = %d", $key['pid'],$key['des'], $key['wid'], $fid);
		}
	}
}

function theme_photos_editlist_x(&$form) {
	$node = node_load(arg(1));
	if($node->type == 'photos'){
		$title = '移动相册';
	}else{
		$title = '所属相册';
	}
	$header = array(
		array('data' => '删除','align'=> 'center','width' => 60),
		array('data' => '缩略图','align'=> 'center','width' => 120),
		array('data' => '描述','align'=> 'center'),
		array('data' => $title,'align'=> 'center'),
		array('data' => '排序','align'=> 'center','width' => 60)
	);
	if(!empty($node->photos['count']) || !empty($node->album['count']) || _photos_num('album')){
	    foreach (element_children($form) as $key) {
			$row = array();
			$row[] = drupal_render($form[$key]['del']);
			$row[] = drupal_render($form[$key]['path']);
			$row[] = drupal_render($form[$key]['des']);
			$row[] = drupal_render($form[$key]['pid']);
			$row[] = drupal_render($form[$key]['wid']);
			$rows[] = $row;
			$rows[] = array(array('data' => drupal_render($form[$key]['time']), 'class'=> 'photos-des','colspan' => '5'));
			
	    }
    }else {
		$rows[] = array(array('data' => '还没有图片', 'colspan' => '5'));
	}

	$output = theme('table', $header, $rows,array('id'=>'imagesedit'));
	$output .= theme('pager', NULL, 10, 0);
	$output .= drupal_render($form['allck']);
	$output .= drupal_render($form['submit']);
	
	return $output;
}

//
function _photos_getval($ImageInfo,$val_arr) {
    $InfoVal = '未知';
    foreach($val_arr as $name=>$val) {
        if ($name==$ImageInfo) {
            $InfoVal = &$val;
            break;
        }
    }
    return $InfoVal;
}
function _photos_getexif($img,$type = false,$url = false) {
    $imgtype = array("", "GIF", "JPG", "PNG", "SWF", "PSD", "BMP", "TIFF(intel byte order)", "TIFF(motorola byte order)", "JPC", "JP2", "JPX", "JB2", "SWC", "IFF", "WBMP", "XBM");
    $Orientation = array("", "top left side", "top right side", "bottom right side", "bottom left side", "left side top", "right side top", "right side bottom", "left side bottom");
    $ResolutionUnit = array("", "", "英寸", "厘米");
    $YCbCrPositioning = array("", "the center of pixel array", "the datum point");
    $ExposureProgram = array("未定义", "手动", "标准程序", "光圈先决", "快门先决", "景深先决", "运动模式", "肖像模式", "风景模式");
    $MeteringMode_arr = array(
        "0"        =>    "未知",
        "1"        =>    "平均",
        "2"        =>    "中央重点平均测光",
        "3"        =>    "点测",
        "4"        =>    "分区",
        "5"        =>    "评估",
        "6"        =>    "局部",
        "255"    =>    "其他"
        );
    $Lightsource_arr = array(
        "0"        =>    "未知",
        "1"        =>    "日光",
        "2"        =>    "荧光灯",
        "3"        =>    "钨丝灯",
        "10"    =>    "闪光灯",
        "17"    =>    "标准灯光A",
        "18"    =>    "标准灯光B",
        "19"    =>    "标准灯光C",
        "20"    =>    "D55",
        "21"    =>    "D65",
        "22"    =>    "D75",
        "255"    =>    "其他"
        ); 
    $Flash_arr = array(
        "0"        =>    "flash did not fire",
        "1"        =>    "flash fired",
        "5"        =>    "flash fired but strobe return light not detected",
        "7"        =>    "flash fired and strobe return light detected",
        );
   
    $exif = @exif_read_data ($img,"IFD0");
    if ($exif) {
        $exif = exif_read_data($img,0,true);
        if($type == 't'){
	        $new_img_info = array (
	            "作者"   => $exif[IFD0][Artist],
	            "文件名" => $exif[FILE][FileName],
	            "文件类型" => $imgtype[$exif[FILE][FileType]],
	            "文件格式" => $exif[FILE][MimeType],
	            "文件大小" => (floor($exif[FILE][FileSize] / 1024 * 10 )/10)."KB",
	            "时间戳" => date("Y:m:d H:i:s",$exif[FILE][FileDateTime]),
	            "制造商" => $exif[IFD0][Make],
	            "型号" => $exif[IFD0][Model],
	            "修改时间"  => $exif[IFD0][DateTime],
	            "Exif版本" => $exif[EXIF][ExifVersion],
	            "拍摄时间"  => $exif[EXIF][DateTimeOriginal],
	            "数字化时间" => $exif[EXIF][DateTimeDigitized],
	            "拍摄高度" => $exif[COMPUTED][Height].'px',
	            "拍摄宽度" => $exif[COMPUTED][Width].'px',
	            "压缩率" => $exif[EXIF][CompressedBitsPerPixel]."Bits/Pixel",
	            "对焦距离" => !empty($exif[COMPUTED][FocusDistance]) ? $exif[COMPUTED][FocusDistance]."m":NULL,
	            "焦距"  => !empty($exif[EXIF][FocalLength]) ? $exif[EXIF][FocalLength]."mm":NULL,
	            "等价35mm焦距"  => !empty($exif[EXIF][FocalLengthIn35mmFilm]) ? $exif[EXIF][FocalLengthIn35mmFilm]."mm":NULL,
	            "色彩空间" =>  ($exif[EXIF][ColorSpace]==1?"sRGB":"Uncalibrated"), 
	        );
	        $more = l('查看详细',$url);
        }else{
	        $new_img_info = array (
	            "文件名" => $exif[FILE][FileName],
	            "文件类型" => $imgtype[$exif[FILE][FileType]],
	            "文件格式" => $exif[FILE][MimeType],
	            "文件大小" => (floor($exif[FILE][FileSize] / 1024 * 10 )/10)."KB",
	            "时间戳" => date("Y-m-d H:i:s",$exif[FILE][FileDateTime]),
	            "图片说明"  => $exif[IFD0][ImageDescription],
	            "制造商" => $exif[IFD0][Make],
	            "型号" => $exif[IFD0][Model],
	            "方向" => $Orientation[$exif[IFD0][Orientation]],
	            "水平分辨率" => $exif[IFD0][XResolution].$ResolutionUnit[$exif[IFD0][ResolutionUnit]],
	            "垂直分辨率" => $exif[IFD0][YResolution].$ResolutionUnit[$exif[IFD0][ResolutionUnit]],
	            "创建软件"  => drupal_convert_to_utf8($exif[IFD0][Software],'gbk'),
	            "修改时间"  => $exif[IFD0][DateTime],
	            "作者"   => $exif[IFD0][Artist],
	            "YCbCr位置控制" => $YCbCrPositioning[$exif[IFD0][YCbCrPositioning]],
	            "版权"  => $exif[IFD0][Copyright],
	            "摄影版权" => $exif[COMPUTED][Copyright.Photographer],
	            "编辑版权"  => $exif[COMPUTED][Copyright.Editor],
	            "Exif版本" => $exif[EXIF][ExifVersion],
	            "FlashPix版本" => "Ver. ".number_format($exif[EXIF][FlashPixVersion]/100,2),
	            "拍摄时间"  => $exif[EXIF][DateTimeOriginal],
	            "数字化时间" => $exif[EXIF][DateTimeDigitized],
	            "拍摄高度" => $exif[COMPUTED][Height].'px',
	            "拍摄宽度" => $exif[COMPUTED][Width].'px',
	            "光圈" => $exif[EXIF][ApertureValue],
	            "快门速度" => $exif[EXIF][ShutterSpeedValue],
	            "快门光圈" => $exif[COMPUTED][ApertureFNumber], 
	            "最大光圈值"  =>  "F".$exif[EXIF][MaxApertureValue],
	            "曝光时间" => $exif[EXIF][ExposureTime],
	            "F-Number" => $exif[EXIF][FNumber],
	            "测光模式"  =>    _photos_getval($exif[EXIF][MeteringMode],$MeteringMode_arr),
	            "光源" => _photos_getval($exif[EXIF][LightSource], $Lightsource_arr),
	            "闪光灯" => _photos_getval($exif[EXIF][Flash], $Flash_arr),
	            "曝光模式" => ($exif[EXIF][ExposureMode]==1?"手动":"自动"),
	            "白平衡" =>  ($exif[EXIF][WhiteBalance]==1?"手动":"自动"),
	            "曝光程序" =>  $ExposureProgram[$exif[EXIF][ExposureProgram]],
	            "曝光补偿"  => $exif[EXIF][ExposureBiasValue]."EV",
	            "ISO感光度"  => $exif[EXIF][ISOSpeedRatings],
	            "分量配置"  =>    (bin2hex($exif[EXIF][ComponentsConfiguration])=="01020300"?"YCbCr":"RGB"),
	            "图像压缩率" => $exif[EXIF][CompressedBitsPerPixel]."Bits/Pixel",
	            "对焦距离" => $exif[COMPUTED][FocusDistance]."m",
	            "焦距"  => $exif[EXIF][FocalLength]."mm",
	            "等价35mm焦距"  => $exif[EXIF][FocalLengthIn35mmFilm]."mm",
	            "用户注释编码" => $exif[COMPUTED][UserCommentEncoding],
	            "用户注释" => $exif[COMPUTED][UserComment],
	            "色彩空间" =>  ($exif[EXIF][ColorSpace]==1?"sRGB":"Uncalibrated"), 
	            "Exif图像宽度" => $exif[EXIF][ExifImageLength],
	            "Exif图像高度" =>  $exif[EXIF][ExifImageWidth],
	            "文件来源"  => (bin2hex($exif[EXIF][FileSource])==0x03?"数码相机":"未知"),
	            "场景类型"  =>  (bin2hex($exif[EXIF][SceneType])==0x01?"A directly photographed image":"unknown"),
	            "缩略图文件格式" => $exif[COMPUTED][Thumbnail.FileType],
	            "缩略图Mime格式" => $exif[COMPUTED][Thumbnail.MimeType]
	        );
        }
    }elseif($type != 't'){
    	$new_img_info = array ("文件信息" => "这张图片没有EXIF信息");
    }
    
	$output = '';
	if($new_img_info){
		$header = array(array('data'=>'EXIF信息'),array('data'=>$more,'class'=>'rg'));
		foreach($new_img_info as $name=>$val) {
		    $row = array();
		    if($val){
		    	$row[] = $name;
		    	$row[] = $val;
		    	$rows[] = $row;
		    }
		} 
		$output = theme('table', $header, $rows,array('id'=>'photo-exif'));
	}				
    return $output;
}